home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-k-archive.past / tex-k-archive.gz / tex-k-archive / 000319_bon@LTE.E-TECH…uni-erlangen.de_Tue, 15 Feb 1994 21:42:50 +0100.msg < prev    next >
Internet Message Format  |  1994-10-11  |  9KB

  1. Received: from lte.lte.e-technik.uni-erlangen.de (lte.e-technik.uni-erlangen.de) by cs.umb.edu with SMTP id AA14266
  2.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Tue, 15 Feb 1994 18:35:11 -0500
  3. Message-Id: <199402152335.AA14266@cs.umb.edu>
  4. Received: by lte.lte.e-technik.uni-erlangen.de
  5.     (1.37.109.8/16.2) id AA15013; Tue, 15 Feb 1994 21:42:50 +0100
  6. Date: Tue, 15 Feb 1994 21:42:50 +0100
  7. From: Uwe Bonnes <bon@LTE.E-TECHNIK.uni-erlangen.de>
  8. To: tex-k@cs.umb.edu
  9. Subject: Making xdvi understand \psfig{...,angle=xx}
  10.  
  11. Appended you find a patch to make xdvik-1.6 understand the angle option from
  12. psfig 1.10.
  13.  
  14.  
  15.  
  16. Uwe Bonnes  bon@lte.e-technik.uni-erlangen.de
  17.  
  18. *** tpic.cln.c    Tue Feb 15 20:59:13 1994
  19. --- tpic.c    Tue Feb 15 20:14:48 1994
  20. ***************
  21. *** 429,434 ****
  22. --- 429,436 ----
  23.       else if (strncmp(orig_cp, "ps::[begin]", 11)==0) psfig_setup(orig_cp);
  24.       else if (strncmp(orig_cp, "ps::[end]", 9) == 0) /* nop */ ;
  25.       else if (strncmp(orig_cp, "ps: plotfile ", 13) == 0) psfig(orig_cp);
  26. +     else if (strncmp(orig_cp, "ps::", 4)==0) psfig_setup_angle(orig_cp); 
  27. +             /* check as last ps:: option! */
  28.       else if (!hush_spec_now)
  29.           Fprintf(stderr, "%s:  special \"%s\" not implemented\n", prog,
  30.           orig_cp);
  31. *** epsf.cln.c    Tue Feb 15 18:55:23 1994
  32. --- epsf.c    Tue Feb 15 21:39:55 1994
  33. ***************
  34. *** 104,113 ****
  35.     }
  36.   }
  37.   
  38.   struct cache_node {
  39.     char   *filename;
  40.     time_t mtime;
  41. !   float  scale;
  42.     int    resolution;
  43.     struct bitmap *bm;
  44.     struct cache_node *next;
  45. --- 104,133 ----
  46.     }
  47.   }
  48.   
  49. + /*
  50. +  * Simple sscanf version of finding psfig angle parameters.
  51. +  */
  52. + static Boolean
  53. + parse_psfig_angle(special,angle)
  54. +   char *special;
  55. +   float  *angle;
  56. +  
  57. + {
  58. +   if (no_epsf) return;
  59. +   if (sscanf(special, "ps:: %f rotate",
  60. +               angle) == 1){
  61. +     return True;
  62. +   } else 
  63. +     {
  64. +       Moan("\"%s\" not understood.", special);
  65. +       return False;
  66. +     }
  67. + }
  68.   struct cache_node {
  69.     char   *filename;
  70.     time_t mtime;
  71. !   float  scale, angle;
  72.     int    resolution;
  73.     struct bitmap *bm;
  74.     struct cache_node *next;
  75. ***************
  76. *** 163,177 ****
  77.    * Try to find a bitmap for psfname, at the given scale and res, in the cache. 
  78.    */
  79.   static struct bitmap *
  80. ! find_bitmap(psfname, x_scale, y_scale, res)
  81.     char  *psfname;
  82. !   float x_scale, y_scale;
  83.     int   res;
  84.   {
  85.     struct cache_node *ll, *pred;
  86.   
  87.     for (ll=cache, pred=NULL;  ll;  pred=ll, ll=ll->next) {
  88. !     if (ll->resolution==res && ll->scale==x_scale &&
  89.       strcmp(ll->filename, psfname)==0) {    
  90.         if (mod_time_of(psfname) == ll->mtime) {
  91.       return ll->bm;
  92. --- 183,197 ----
  93.    * Try to find a bitmap for psfname, at the given scale and res, in the cache. 
  94.    */
  95.   static struct bitmap *
  96. ! find_bitmap(psfname, x_scale, y_scale, angle, res)
  97.     char  *psfname;
  98. !   float x_scale, y_scale, angle;
  99.     int   res;
  100.   {
  101.     struct cache_node *ll, *pred;
  102.   
  103.     for (ll=cache, pred=NULL;  ll;  pred=ll, ll=ll->next) {
  104. !     if (ll->resolution==res && ll->scale==x_scale && ll->angle==angle&&
  105.       strcmp(ll->filename, psfname)==0) {    
  106.         if (mod_time_of(psfname) == ll->mtime) {
  107.       return ll->bm;
  108. ***************
  109. *** 198,204 ****
  110.    * Get it from the cache, or generate it using ghostscript.
  111.    */
  112.   static struct bitmap *
  113. ! get_bitmap(psfname, x_scale, y_scale, llx, lly, urx, ury)
  114.     /* 
  115.      * When psfname is interpreted at scale, it'll produce 
  116.      * a bounding box of (llx,lly), (urx,ury).  Scale and (llx,lly),(urx,ury)
  117. --- 218,224 ----
  118.    * Get it from the cache, or generate it using ghostscript.
  119.    */
  120.   static struct bitmap *
  121. ! get_bitmap(psfname, x_scale, y_scale, llx, lly, urx, ury,angle)
  122.     /* 
  123.      * When psfname is interpreted at scale, it'll produce 
  124.      * a bounding box of (llx,lly), (urx,ury).  Scale and (llx,lly),(urx,ury)
  125. ***************
  126. *** 206,212 ****
  127.      * xdvi is running at to take care of shrink_factor.
  128.      */
  129.     char *psfname;
  130. !   float x_scale, y_scale;
  131.     int llx, lly, urx, ury;
  132.   { 
  133.     int line, status;
  134. --- 226,232 ----
  135.      * xdvi is running at to take care of shrink_factor.
  136.      */
  137.     char *psfname;
  138. !   float x_scale, y_scale, angle;
  139.     int llx, lly, urx, ury;
  140.   { 
  141.     int line, status;
  142. ***************
  143. *** 215,221 ****
  144.     char *name;
  145.     struct bitmap *result;
  146.   
  147. !   result = find_bitmap(psfname, x_scale, y_scale, RESOLUTION);
  148.     if (result) return result;
  149.   
  150.     /* Build it and they will come. */
  151. --- 235,241 ----
  152.     char *name;
  153.     struct bitmap *result;
  154.   
  155. !   result = find_bitmap(psfname, x_scale, y_scale, angle, RESOLUTION);
  156.     if (result) return result;
  157.   
  158.     /* Build it and they will come. */
  159. ***************
  160. *** 265,273 ****
  161.   
  162.     tmpnam(tempfilename);
  163.     sprintf(command, 
  164. !       "(echo %d %d translate %f %f scale; cat %s; echo showpage) \
  165.   | %s -q -sDEVICE=bit -r%d -g%dx%d -sOutputFile=%s -",
  166. !       -llx, -lly, x_scale, y_scale, name, GSEXEC, RESOLUTION,
  167.         (int)result->w, (int)result->h, tempfilename);
  168.   
  169.     if (!(debug & DBG_EPS))
  170. --- 285,293 ----
  171.   
  172.     tmpnam(tempfilename);
  173.     sprintf(command, 
  174. !       "(echo %d %d translate %f %f scale %f rotate; cat %s;echo showpage) \
  175.   | %s -q -sDEVICE=bit -r%d -g%dx%d -sOutputFile=%s -",
  176. !       -llx, -lly, x_scale, y_scale, angle, name, GSEXEC, RESOLUTION,
  177.         (int)result->w, (int)result->h, tempfilename);
  178.   
  179.     if (!(debug & DBG_EPS))
  180. ***************
  181. *** 396,401 ****
  182. --- 416,422 ----
  183.       new_head->filename   = (char *) xstrdup(psfname);
  184.       new_head->mtime      = mod_time_of(psfname);
  185.       new_head->scale      = x_scale;
  186. +     new_head->angle      = angle;
  187.       new_head->resolution = RESOLUTION;
  188.       new_head->bm         = result;
  189.       new_head->next       = cache;
  190. ***************
  191. *** 441,447 ****
  192.       put_grey_rectangle(PXL_H, PXL_V - PT2PXL(ury-lly), 
  193.                  PT2PXL(urx-llx+1), PT2PXL(ury-lly+1));
  194.     } else {
  195. !     bitmap = get_bitmap(psfilename, epsf_scale, epsf_scale, llx, lly, urx, ury);
  196.       if (bitmap) {
  197.         put_bitmap(bitmap, PXL_H, PXL_V - PT2PXL(ury-lly));
  198.       } else {
  199. --- 462,468 ----
  200.       put_grey_rectangle(PXL_H, PXL_V - PT2PXL(ury-lly), 
  201.                  PT2PXL(urx-llx+1), PT2PXL(ury-lly+1));
  202.     } else {
  203. !     bitmap = get_bitmap(psfilename, epsf_scale, epsf_scale, llx, lly, urx, ury,0);
  204.       if (bitmap) {
  205.         put_bitmap(bitmap, PXL_H, PXL_V - PT2PXL(ury-lly));
  206.       } else {
  207. ***************
  208. *** 458,483 ****
  209.    * where each parameter is in scaled points (65536sp/TeXpt)
  210.    */
  211.   
  212. ! static int psfig_ok = 0;
  213.   static int psfig_llx, psfig_lly, psfig_urx, psfig_ury;
  214.   static int psfig_width, psfig_height;
  215.   
  216.   void
  217.   psfig_setup(special)
  218.     char *special;
  219.   {
  220.     if (no_epsf) return;
  221.     psfig_ok = parse_psfig_special(special, &psfig_width, &psfig_height,
  222.                                 &psfig_llx, &psfig_lly, 
  223.                                 &psfig_urx, &psfig_ury);
  224.   }
  225.   
  226.   void
  227.   psfig(special)
  228.        char *special;
  229.   {
  230.     char psfilename[256];
  231. !   float x_scale, y_scale;
  232.     struct bitmap *bitmap;
  233.     int llx, lly, urx, ury;
  234.     int width, height;
  235. --- 479,514 ----
  236.    * where each parameter is in scaled points (65536sp/TeXpt)
  237.    */
  238.   
  239. ! static int psfig_ok = 0, psfig_angle_ok = 0;
  240.   static int psfig_llx, psfig_lly, psfig_urx, psfig_ury;
  241.   static int psfig_width, psfig_height;
  242. + static float psfig_angle;
  243.   
  244.   void
  245.   psfig_setup(special)
  246.     char *special;
  247.   {
  248.     if (no_epsf) return;
  249. +   psfig_angle =0.0;  /* default angle is zero */
  250.     psfig_ok = parse_psfig_special(special, &psfig_width, &psfig_height,
  251.                                 &psfig_llx, &psfig_lly, 
  252.                                 &psfig_urx, &psfig_ury);
  253.   }
  254.   
  255.   void
  256. + psfig_setup_angle(special)
  257. +   char *special;
  258. + {
  259. +   if (no_epsf) return;
  260. +   psfig_angle_ok = parse_psfig_angle(special, &psfig_angle);
  261. + }
  262. + void
  263.   psfig(special)
  264.        char *special;
  265.   {
  266.     char psfilename[256];
  267. !   float x_scale, y_scale, angle;
  268.     struct bitmap *bitmap;
  269.     int llx, lly, urx, ury;
  270.     int width, height;
  271. ***************
  272. *** 485,491 ****
  273.   
  274.     if (!psfig_ok)
  275.       return;
  276.     if (sscanf(special, "ps: plotfile %s ", psfilename) != 1)
  277.       {
  278.         Moan("\"%s\" not understood.", special);
  279. --- 516,521 ----
  280. ***************
  281. *** 515,521 ****
  282.       put_grey_rectangle(PXL_H, PXL_V,
  283.                  PT2PXL(urx-llx+1), PT2PXL(ury-lly+1));
  284.     } else {
  285. !     bitmap = get_bitmap(psfilename, x_scale, y_scale, llx, lly, urx, ury);
  286.       if (bitmap) {
  287.         put_bitmap(bitmap, PXL_H, PXL_V);
  288.       } else {
  289. --- 545,551 ----
  290.       put_grey_rectangle(PXL_H, PXL_V,
  291.                  PT2PXL(urx-llx+1), PT2PXL(ury-lly+1));
  292.     } else {
  293. !     bitmap = get_bitmap(psfilename, x_scale, y_scale, llx, lly, urx, ury,psfig_angle);
  294.       if (bitmap) {
  295.         put_bitmap(bitmap, PXL_H, PXL_V);
  296.       } else {